package com.ruoyi.web.group.player.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.ruoyi.web.group.player.dto.PlayerQueryDTO;
import com.ruoyi.web.group.player.entity.Players;
import com.ruoyi.web.group.player.mapper.PlayersMapper;
import com.ruoyi.web.group.player.service.PlayersService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PlayersServiceImpl extends ServiceImpl<PlayersMapper, Players> implements PlayersService {
    @Override
    public List<Players> findList(PlayerQueryDTO playersDTO) {
        QueryWrapper<Players> qw = new QueryWrapper<>();
        if(playersDTO.getName()!=null && playersDTO.getName() !=""){
            qw.like("name",playersDTO.getName());
        }
        if(playersDTO.getPhone()!=null && playersDTO.getPhone()!=""){
            qw.eq("phone",playersDTO.getPhone());
        }
        if(playersDTO.getTeamId()!=null && playersDTO.getTeamId()!=0){
            qw.eq("team_id",playersDTO.getTeamId());
        }
        return baseMapper.selectPage(new Page<Players>(playersDTO.getPageNum(),playersDTO.getPageSize()),qw).getRecords();
    }
}
